#include <iostream>
#include <vector>

using namespace std;

template <typename Comparable>
void insertionsort( vector<Comparable> & a, int n )
{
    int i, j;
    for ( i = 1; i < n; i++ )
    {
        Comparable tmp = a[ i ];
        for ( j = i; j > 0 && tmp < a[ j - 1 ]; j-- )
            a[ j ] = a[ j - 1 ];
        a[ j ] = tmp;
    }
}

int main( )
{
    vector<int> a ( 20000 );
    int n, m, i;
    while ( cin >> n >> m )
    {
        for ( i = 0; i < n + m; i++ )
            cin >> a[ i ];
        insertionsort( a, n + m );
        cout << a[ 0 ];
        for ( i = 1; i < n + m; i++ )
            if ( a[ i ] != a[ i - 1 ] )
                cout << ' ' << a[ i ];
        cout << endl;
    }
    return 0;
}
